/*
 *  HitTest.cpp
 *  Brawlers
 *
 *  Created by Leroy Ketelaars on 9/28/09.
 *  Copyright 2009 Zombies on Fire. All rights reserved.
 *
 */

#include "HitTest.h"

bool HitTest(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2)
{
	if(x2 + w2 < x1)	return false;	//just checking if their
	if(x2 > x1 + w1)	return false;	//bounding boxes even touch

	if(y2 + h2 < y1)	return false;
	if(y2 > y1 + h1)	return false;

	return true;				//bounding boxes intersect
}
bool HitTest(int x1, int y1, int x2, int y2, int w2, int h2)
{
	return HitTest(x1, y1, 1, 1, x2, y2, w2, h2);
}
bool HitTest(int x1, int y1, int w1, int h1, SDL_Rect r)
{
	return HitTest(x1, y1, w1, h1, r.x, r.y, r.w, r.h);;
}
bool HitTest(int x1, int y1, int w1, int h1, BSRect r)
{
	return HitTest(x1, y1, w1, h1, (int)r.x, (int)r.y, r.w, r.h);;
}
bool HitTest(int x1, int y1, SDL_Rect r)
{
	return HitTest(x1, y1, 1, 1, r.x, r.y, r.w, r.h);
}
bool HitTest(int x1, int y1, BSRect r)
{
	return HitTest(x1, y1, 1, 1, (int)r.x, (int)r.y, r.w, r.h);
}
bool HitTest(int x1, int y1, int w1, int h1, QMPoint p, int w2, int h2)
{
	return HitTest(x1, y1, w1, h1, p.x, p.y, w2, h2);
}
bool HitTest(int x1, int y1, QMPoint p, int w2, int h2)
{
	return HitTest(x1, y1, 1, 1, p.x, p.y, w2, h2);
}
bool HitTest(QMPoint p, int w1, int h1, int x2, int y2, int w2, int h2)
{
	return HitTest(p.x, p.y, w1, h1, x2, y2, w2, h2);
}
bool HitTest(QMPoint p, int x2, int y2, int w2, int h2)
{
	return HitTest(p.x, p.y, 1, 1, x2, y2, w2, h2);
}
bool HitTest(QMPoint p, int w1, int h1, SDL_Rect r)
{
	return HitTest(p.x, p.y, w1, h1, r.x, r.y, r.w, r.h);
}
bool HitTest(QMPoint p, int w1, int h1, BSRect r)
{
	return HitTest(p.x, p.y, w1, h1, (int)r.x, (int)r.y, r.w, r.h);
}
bool HitTest(QMPoint p1, int w1, int h1, QMPoint p2, int w2, int h2)
{
	return HitTest(p1.x, p1.y, w1, h1, p2.x, p2.y, w2, h2);
}
bool HitTest(QMPoint p1, QMPoint p2, int w2, int h2)
{
	return HitTest(p1.x, p1.y, 1, 1, p2.x, p2.y, w2, h2);
}
bool HitTest(BSRect r1, BSRect r2)
{
	return HitTest((int)r1.x, (int)r1.y, r1.w, r1.h, (int)r2.x, (int)r2.y, r2.w, r2.h);
}
bool HitTest(BSRect r1, SDL_Rect r2)
{
	return HitTest((int)r1.x, (int)r1.y, r1.w, r1.h, r2.x, r2.y, r2.w, r2.h);
}
bool HitTest(QMPoint p, SDL_Rect r2)
{
	return HitTest(p.x, p.y, 1, 1, r2.x, r2.y, r2.w, r2.h);

}
bool HitTest(QMPoint p, BSRect r2)
{
	return HitTest(p.x, p.y, 1, 1, (int)r2.x, (int)r2.y, r2.w, r2.h);

}
SDL_Rect ToSDLRect(BSRect* r)
{
	SDL_Rect rec = { (Sint16)r->x, (Sint16)r->y, (Uint16)r->w, (Uint16)r->h };
	return rec;
}
BSRect ToBSRect(SDL_Rect* r)
{
	return BSRect((float)r->x, (float)r->y, (Sint32)r->w, (Sint32)r->h);
}